<?php

/**
 * This is the model class for table "luastanamproduksikacangtanah".
 *
 * The followings are the available columns in table 'luastanamproduksikacangtanah':
 * @property integer $ltpkt_id
 * @property integer $ltpkt_kec
 * @property integer $ltpkt_tanam
 * @property integer $ltpkt_panen
 * @property integer $ltpkt_produksi
 * @property double $ltpkt_rata
 * @property integer $ltpkt_tahun
 *
 * The followings are the available model relations:
 * @property Kecamatan $ltpktKec
 */
class Luastanamproduksikacangtanah extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Luastanamproduksikacangtanah the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'luastanamproduksikacangtanah';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('ltpkt_kec, ltpkt_tanam, ltpkt_panen, ltpkt_produksi, ltpkt_tahun', 'numerical', 'integerOnly'=>true),
			array('ltpkt_rata', 'numerical'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ltpkt_id, ltpkt_kec, ltpkt_tanam, ltpkt_panen, ltpkt_produksi, ltpkt_rata, ltpkt_tahun', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'ltpktKec' => array(self::BELONGS_TO, 'Kecamatan', 'ltpkt_kec'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ltpkt_id' => 'Ltpkt',
			'ltpkt_kec' => 'Kecamatan',
			'ltpkt_tanam' => 'Luas Tanam(Ha)',
			'ltpkt_panen' => 'Luas Panen(Ha)',
			'ltpkt_produksi' => 'Produksi(Ton)',
			'ltpkt_rata' => 'Rata-Rata',
			'ltpkt_tahun' => 'Tahun',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ltpkt_id',$this->ltpkt_id);
		$criteria->compare('ltpkt_kec',$this->ltpkt_kec);
		$criteria->compare('ltpkt_tanam',$this->ltpkt_tanam);
		$criteria->compare('ltpkt_panen',$this->ltpkt_panen);
		$criteria->compare('ltpkt_produksi',$this->ltpkt_produksi);
		$criteria->compare('ltpkt_rata',$this->ltpkt_rata);
		$criteria->compare('ltpkt_tahun',$this->ltpkt_tahun);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}